package com.lk.lkappearance.service.impl;

import com.lk.lkappearance.common.AbstractBaseService;
import com.lk.lkappearance.mapper.DictionaryMapper;
import com.lk.lkappearance.model.Dictionary;
import com.lk.lkappearance.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

public class DictionaryServiceImpl extends AbstractBaseService implements DictionaryService {

    @Autowired
    private DictionaryMapper dictionaryMapper;
    /**
     * @param dictionary
     * @return
     */
    @Override
    public Map<String, Object> add(Dictionary dictionary){
        try {
            dictionaryMapper.insertSelective(dictionary);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    /**
     * @param dictionary
     * @return
     */
    @Override
    public Map<String, Object> modify(Dictionary dictionary) {
        try {
            dictionaryMapper.updateByPrimaryKeySelective(dictionary);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    /**
     * @param dictionaryId
     * @return
     */
    @Override
    public Map<String, Object> delete(String dictionaryId) {
        try {
            dictionaryMapper.deleteByPrimaryKey(dictionaryId);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> getList(Dictionary dictionary) {
        try {
            dictionaryMapper.getList(dictionary);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> getListExcel(Dictionary dictionary) {
        try {
            dictionaryMapper.getList(dictionary);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

    @Override
    public Map<String, Object> insertList(List<Dictionary> dictionary) {
        try {
            for (Dictionary dic:dictionary) {
                dictionaryMapper.insertSelective(dic);
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        return success().getResult();
    }

}
